const { app, BrowserWindow, nativeImage } = require("electron");
const path = require("path");
const icon = nativeImage.createFromPath("icons/icon.png");

const CreateMainWindow = () => {
    const mainWindow = new BrowserWindow({
        width: 1280,
        height: 800,
        titleBarStyle: "hidden",
        icon: icon,
        // transparent: true,
        webPreferences: {
            preload: path.join(__dirname, "../preload/preload.js"),
        },
    });
    if (app.isPackaged) {
        mainWindow.loadFile(path.join(__dirname, `../../.vite/renderer/main_window/Main.html`));
    } else {
        mainWindow.loadURL(`http://localhost:5173/Main.html`);
    }
    mainWindow.on("close", (e) => { });
    mainWindow.on("maximize", () => {
        mainWindow.webContents.send("change-max-state", "maximize");
    });
    mainWindow.on("unmaximize", () => {
        mainWindow.webContents.send("change-max-state", "unmaximize");
    });
    mainWindow.on("minimize", () => {
        mainWindow.webContents.send("change-max-state", "minimize");
    });
    return mainWindow;
};

module.exports = {
    CreateMainWindow,
};
